<template>
  <sv-page>
    <!-- 列表 -->
    <view class="cu-list menu sm-border sv-cu-list padding-tb-sm">
      <view class="cu-item arrow" v-for="item in libData" :key="item.lib_id" @click="onLib(item)">
        <view class="content">
          <text :class="item.icon"></text>
          <text>{{ item.lib_name }}</text>
        </view>
      </view>
    </view>
  </sv-page>
</template>

<script setup>
import { ref } from 'vue'
import { onLoad } from '@dcloudio/uni-app'
import { store } from '@/uni_modules/sv-id-pages/common/store'
import { buyLibList } from '@/service/api/record'

const libData = ref([])

onLoad(async () => {
  uni.showLoading({ title: '加载中' })
  const libRes = await buyLibList({ user_id: store.userInfo._id })
  libData.value = libRes.data || []
  console.log('==== libData :', libData.value)
  uni.hideLoading()
})

function onLib(item) {
  uni.navigateTo({
    url: `/pages/lib-detail/lib-detail?lib_id=${item.lib_id}&lib_name=${item.lib_name}`
  })
}
</script>

<style></style>
